package com.solomon.travel.common.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.solomon.travel.common.custom.mapper.AnnounceCustomMapper;
import com.solomon.travel.common.mapper.AnnounceMapper;
import com.solomon.travel.common.model.Page;
import com.solomon.travel.common.po.Announce;
import com.solomon.travel.common.po.AnnounceExample;
import com.solomon.travel.common.service.AnnounceService;

@Service
public class AnnounceServiceImpl implements AnnounceService {
	
	@Resource
	private AnnounceMapper announceMapper;
	
	@Resource
	private AnnounceCustomMapper announceCustomMapper;

	@Override
	public int publish(Announce announce) {
		return announceMapper.insertSelective(announce);
	}

	@Override
	public int countByType(Integer type) {
		AnnounceExample example = new AnnounceExample();
		example.createCriteria().andTypeEqualTo(type);
		return announceMapper.countByExample(example);
	}

	@Override
	public List<Announce> listByType(String fromUser,Integer type,Page page) {
		return announceCustomMapper.listByType(fromUser,type, page);
	}

	@Override
	public Announce getById(String announceId) {
		return announceMapper.selectByPrimaryKey(announceId);
	}

	@Override
	public int update(Announce announce) {
		return announceMapper.updateByPrimaryKeySelective(announce);
	}

	@Override
	public int delete(String announceId) {
		return announceMapper.deleteByPrimaryKey(announceId);
	}

}
